package com.cetccloud.ap.proxy.channel.cossDomain.s30.handler.recv;

import cn.hutool.core.util.StrUtil;
import com.cetccloud.ap.proxy.channel.Channel;
import com.thunisoft.exchange.gateway.protocol.channel.GatewayChannelMessageType;
import com.thunisoft.exchange.gateway.protocol.channel.GatewayDataMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @ClassName MessageHandler
 * @Description TODO
 * @Author superz
 * @Date 2021/4/23 16:27
 * @Version 1.0
 **/
@Component("recvMessageHandler")
public class MessageHandler implements RecvChannelHandler<GatewayDataMessage> {

    @Autowired
    private Channel crossDomainChannel;

    @Override
    public GatewayChannelMessageType type() {
        return GatewayChannelMessageType.message;
    }

    @Override
    public void handle(GatewayDataMessage channelMessage) {
        String data = StrUtil.str(channelMessage.getData(), "utf-8");
        crossDomainChannel.receive(data);
    }
}
